package com.mioto.ld.module.device.controller.app;

import com.mioto.ld.module.statistics.model.AppAlertStatisticVO;
import com.mioto.ld.module.statistics.StatisticsFactory;
import com.mioto.ld.module.statistics.model.AppMaterialSaleStatisticsVO;
import com.mioto.ld.module.statistics.model.AppStatisticSearchDTO;
import com.mioto.ld.module.statistics.model.MaterialSaleSearchDTO;
import com.mioto.ld.result.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mioto-qinxj
 * @date 2024/6/18
 * @desc
 */
@RestController
@RequestMapping("/app/statistic")
@Api(tags = "app统计")
public class AppStatisticController {

    @GetMapping("/alert")
    @ApiOperation(value="告警统计",response = AppAlertStatisticVO.class)
    public ResultData alertStatistic (AppStatisticSearchDTO searchDTO){
        return ResultData.success(StatisticsFactory.create(searchDTO.getSearchType()).appAlertStatistics(searchDTO));
    }

    @GetMapping("/deviceSale")
    @ApiOperation(value="设备销量统计",response = AppAlertStatisticVO.class)
    public ResultData deviceSaleStatistics (AppStatisticSearchDTO searchDTO){
        return ResultData.success(StatisticsFactory.create(searchDTO.getSearchType()).appDeviceSaleStatistics(searchDTO));
    }

    @GetMapping("/materialSale")
    @ApiOperation(value="材料销量统计",response = AppMaterialSaleStatisticsVO.class)
    public ResultData materialSaleStatistics (MaterialSaleSearchDTO searchDTO){
        return ResultData.success(StatisticsFactory.create(searchDTO.getSearchType()).appMaterialSaleStatistics(searchDTO));
    }
}
